package struts.action;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import personne.Personne;

import dao.DAOPersonneHBM;
import dao.DaoPersonne;

public class ActionAfficherPersonne extends Action {
	
	private DaoPersonne dao = null;

	public ActionAfficherPersonne() {
		
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		System.out.println("je suis la");
		ArrayList<Personne> liste = dao.loadAll();
		if(liste!=null)
		{
			request.setAttribute("personnes", liste);
			return mapping.findForward("personnes");
		}
		return mapping.findForward("erreurs");
	}

	public DaoPersonne getDao() {
		return dao;
	}

	public void setDao(DaoPersonne dao) {
		this.dao = dao;
	}
	
	

}
